<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.prime.com.tr/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html">
    <body>
        <ui:composition template="../templates/default3.xhtml">         
            <ui:define name="content">
                <h:form id="addLead" binding="#{leadManagerBean.loadAddLead}">
 
                    <p:messages/>
                    <p:panel header="Lead Information" id="addLead">
                        
                        <font class="fieldNote">* - Mandatory Field<br/><br/></font> 
                        <table>
                            <tr>
                                <td width ="80px">Employee:</td>
                                <td width="200px"> 
                                    <p:inputText required="true" id="userId"  disabled ="true" value="#{leadManagerBean.userId}">                                       
                                    </p:inputText> <!-- Why this one need to validate since it is given from the system-->
                                </td>
                            </tr>
                            <tr>
                                <td>Email:</td>
                                <td width="200px"> 
                                    <p:inputText required="true" id="email" requiredMessage="Email Address Required" value="#{leadManagerBean.email}" validatorMessage="Invalid Email Address Format">   
                                        <f:validateRegex pattern="^(([A-Za-z0-9]+_+)|([A-Za-z0-9]+\-+)|([A-Za-z0-9]+\.+)|([A-Za-z0-9]+\++))*[A-Za-z0-9]+@((\w+\-+)|(\w+\.))*\w{1,63}\.[a-zA-Z]{2,6}$" />                                   
                                    </p:inputText>
                                    <font class="fieldNote">*</font> 
                                </td>
                                <td width="80px">Company:</td>
                                <td>
                                    <p:inputText required="true" id="company" requiredMessage="Company Required" value="#{leadManagerBean.company}">
                                    </p:inputText>
                                    <font class="fieldNote">*</font> 
                                </td>
                            </tr>      
                            <tr>
                                <td>First Name:</td>
                                <td>
                                    <p:inputText required="true" id="fname" requiredMessage="First Name Required" value="#{leadManagerBean.firstName}"> 
                                    </p:inputText>
                                    <font class="fieldNote">*</font> 
                                </td>
                                <td>Title:</td>
                                <td>                                                                               
                                    <p:inputText required="true" id="title" requiredMessage="Title Required" value="#{leadManagerBean.title}">
                                    </p:inputText>   
                                    <font class="fieldNote">*</font> 
                                </td>
                            </tr>
                            <tr>
                                <td>Last Name:</td>
                                <td>
                                    <p:inputText required="true" id="lname" requiredMessage="Last Name Required" value="#{leadManagerBean.lastName}"> 
                                    </p:inputText>
                                    <font class="fieldNote">*</font> 
                                </td>
                                <td>Status:</td>
                                <td>
                                    <h:selectOneMenu id="status" value="#{leadManagerBean.status}">
                                        <f:selectItem id="Open" itemLabel="Open" itemValue="Open"/>
                                        <f:selectItem id="Contacted" itemLabel="Contacted" itemValue="Contacted"/>
                                        <f:selectItem id="Converted" itemLabel="Converted" itemValue="Converted"/>
                                        <f:selectItem id="Rejected" itemLabel="Rejected" itemValue="Rejected"/>
                                    </h:selectOneMenu>
                                    <font class="fieldNote">*</font> 
                                </td>
                            </tr>
                            <tr>
                                <td>Telephone:</td>
                                <td>                                                          
                                    <p:inputText label="Telephone" required="true" id="phone" requiredMessage="Telephone Required" value="#{leadManagerBean.phone}" validatorMessage="Telephone Must Have a Minimum of 8 Digits">
                                        <f:validateLength minimum="8"/>                                 
                                    </p:inputText>
                                    <font class="fieldNote">* Min. 8</font> 
                                </td>
                                <td>Industry:</td>
                                <td>
                                    <h:selectOneMenu id="industry" value="#{leadManagerBean.industry}">
                                        <f:selectItem id="HC" itemLabel="Health care" itemValue="Health care"/>
                                        <f:selectItem id="Hospitality" itemLabel="Hospitality" itemValue="Hospitality"/>
                                        <f:selectItem id="Entertainment" itemLabel="Entertainment" itemValue="Entertainment"/>
                                        <f:selectItem id="Recreation" itemLabel="Recreation" itemValue="Recreation"/>
                                        <f:selectItem id="Retail" itemLabel="Retail" itemValue="Retail"/>
                                        <f:selectItem id="FB" itemLabel="Food and Beverage" itemValue="Food and Beverage"/>
                                    </h:selectOneMenu>
                                    <font class="fieldNote">*</font> 
                                </td>
                            </tr>
                        </table>
                    </p:panel>
                    <p:panel header="Company Address (Optional)" id="addLead2">
                        <table>
                            <tr>
                                <td width ="80px" valign="top"> Street:</td>
                                <td width="200px" valign="top"> 
                                    <p:inputTextarea id="street" style="width:160px;height:60px;" maxHeight="60" effectDuration="400" value="#{leadManagerBean.street}">                                         
                                    </p:inputTextarea>
                                </td>
                                <td width="80px">City: <br/><br/> Country: </td>
                                <td width="200px">
                                    <p:inputText  id="city" value="#{leadManagerBean.city}"> 
                                    </p:inputText>
                                    <br/><br/>
                                    <p:inputText id="country" value="#{leadManagerBean.country}">
                                    </p:inputText>
                                </td>
                            </tr>
                            <tr>
                                <td valign ="top">Postal: </td>
                                <td width="200px" valign ="top"> 
                                    <p:inputText label="Postal" id="postal" value="#{leadManagerBean.postal}" validatorMessage="Postal Code Must Have a Minimum of 4 Digits and Maximum of 8 Digits">
                                        <f:validateLength minimum="4" maximum="11"/>
                                    </p:inputText>
                                    <br/>
                                    <font class="fieldNote">Min. 4 , Max. 11</font> 
                                </td>
                            </tr>
                        </table>
                    </p:panel>
                    <p:panel header="Remark (Optional) " id="addLead3">
                        <table>
                            <tr>
                                <td width ="80px" valign="top"> Description:</td>
                                <td width="200px" valign="top"> 
                                    <p:inputTextarea id="description" style="width:160px;height:80px;" maxHeight="80" effectDuration="400" value="#{leadManagerBean.description}">
                                    </p:inputTextarea>
                                </td>
                                <td width="80px">Annual revenue: <br/><br/> No. of Employee:</td>
                                <td width="200px">
                                    <p:inputText  label="Anuual Revenue" id="revenue" value="#{leadManagerBean.revenue}">

                                    </p:inputText>

                                    <br/><br/>
                                    <p:inputText label="No. Of Employee" id="no_emp" value="#{leadManagerBean.numEmployee}">
                                    </p:inputText>
                                </td>
                            </tr>
                        </table>
                    </p:panel>
                    <table class="panel">
                        <tr>
                            <td class="btn">  <p:commandButton id="btnAddLead" value="Create Lead" actionListener="#{leadManagerBean.addLead}" update="addLead" ajax="true"/></td>
                        </tr>
                    </table>
                </h:form>
            </ui:define>        
        </ui:composition>
    </body>
</html>